﻿package 
{
	import flash.display.Sprite;
	import flash.display.StageDisplayState;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Point;
	import samples.BaseSample;
	import shapes.shapes2D.curves.Spiral;
	import shapes.shapes2D.distribution.goldenRatio.GoldenRatio;
	import shapes.shapes2D.distribution.modulo.Modulo;
	import shapes.shapes2D.distribution.random.Random;
	import shapes.shapes2D.distribution.trigo.*;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Trigo extends Sprite 
	{
		private var sin:Sine;
		private var cos:Cosine;
		
		public function Trigo():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			_stage = stage;
			_stage.scaleMode = StageScaleMode.NO_SCALE;
			
			//_stage.quality = StageQuality.LOW;
			_stage.displayState = StageDisplayState.FULL_SCREEN;
			
			var sw:int = _stage.stageWidth;
			var sh:int = _stage.stageHeight;
			
			var sample:BaseSample;
			var amplitude:Number = 150;
			var frequence:Number = 60;
			
			///*
			var angle:Number = Math.PI / 2
			cos = new Cosine( angle,  amplitude, frequence );
			//addChild( cos );
			
			sin = new Sine( amplitude, frequence );
			//addChild( sin );
			
			sample = new Log( amplitude );
			//addChild( sample );
			
			sample = new Exp( amplitude );
			//addChild( sample );
			
			sample = new Tan( 20, 60 );
			//addChild( sample );
			
			//*/
			
			addChild( new Pythagora() );
			
			
			//addChild( new Modulo() );
			
			//addChild( new Random() ) ;
			
			
			
			//spirale
			var points:Vector.<Point>;
			
			//points = Spiral.compute( sw / 2, sh / 2, 2, .1, 1000 );	//reguliere
			//points = Spiral.compute( sw / 2, sh / 2, 45, 1, 250 );	//octogone
			//points = Spiral.compute( sw / 2, sh / 2, 90, 1.5, 150 );	//carree
			//points = Spiral.compute( sw / 2, sh / 2, 120, 2, 120 );	//triangle
			
			//points = Spiral.compute( sw / 2, sh / 2, 185, 3, 100 );//etoile
			//points = Spiral.compute( sw / 2, sh / 2, 210, 3, 100 );//etoile
			
			//points = Spiral.compute( sw / 2, sh / 2, GoldenRatio.RATIO, .5, 1000 );
			
			//if ( points != null ) plot( points );
			//
			
		}
		
		private function plot( points:Vector.<Point>):void
		{
			
			var p:Point = points[ 0 ];
			graphics.lineStyle( 0, 0xFFFFFF );
			graphics.moveTo( p.x, p.y );
			
			for each( p in points )
			{
				
				graphics.lineTo( p.x, p.y );
				
			}
			
		}
	}
	
}